/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.teste;

import br.com.modelo.Autor;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author egberto
 */
public class ListaAutoresComJPA {
    
    public static void main(String args[]){
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("default");
        EntityManager manager = factory.createEntityManager();
        
        Query query = manager.createQuery("SELECT a FROM Autor a");
        
        List<Autor> autores = query.getResultList();
        
        for(Autor a : autores){
            System.out.println("Cod.: " + a.getId() + " - Nome: " + a.getNome());
        }
    }
    
}
